/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.cotec.model;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author magalhaes
 */
@Entity
@Table(name = "periferico")
@NamedQueries({@NamedQuery(name = "Periferico.findAll", query = "SELECT p FROM Periferico p"), 
			   @NamedQuery(name = "Periferico.findById", query = "SELECT p FROM Periferico p WHERE p.id = :id"), 
			   @NamedQuery(name = "Periferico.findByCodigo", query = "SELECT p FROM Periferico p WHERE p.codigo = :codigo"), 
			   @NamedQuery(name = "Periferico.findByNome", query = "SELECT p FROM Periferico p WHERE p.nomePeriferico = :nomePeriferico"), 
			   @NamedQuery(name = "Periferico.findByDescricao", query = "SELECT p FROM Periferico p WHERE p.descricao = :descricao")})
public class Periferico implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "codigo", length=20)
    private String codigo;
    @Column(name = "descricao", length=80, nullable=true)
    private String descricao;
    @JoinColumn(name = "nomePeriferico", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private NomePeriferico nomePeriferico;

    public Periferico() {
    	this.setNomePeriferico(new NomePeriferico());
    }

    public Periferico(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public NomePeriferico getNomePeriferico() {
		return nomePeriferico;
	}

	public void setNomePeriferico(NomePeriferico nome) {
		this.nomePeriferico = nome;
	}
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

	@Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Periferico)) {
            return false;
        }
        Periferico other = (Periferico) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.cotec.model.Periferico[id=" + id + "]";
    }

}
